package com.a2.appa3.ui.activity;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.uuzuche.lib_zxing.activity.CodeUtils;
import com.a2.appa3.R;
import com.a2.appa3.global.Info;

import butterknife.BindView;
import me.shihao.library.XStatusBarHelper;

public class ZxingActivity extends BaseActivitySimple {

    @BindView(R.id.back)
    LinearLayout back;
    @BindView(R.id.headerTitle)
    TextView headerTitle;
    @BindView(R.id.userid)
    TextView useridt;
    @BindView(R.id.zxingimg)
    ImageView zxingimg;
    public Bitmap mBitmap = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (android.os.Build.VERSION.SDK_INT >= 21) {
            //解决Android5.0以上，状态栏设置颜色后变灰的问题
            XStatusBarHelper.tintStatusBar(this, getResources().getColor(R.color.settingbg));
        }
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        headerTitle.setText("我的二维码");
        String userid = getIntent().getStringExtra("userid");
        useridt.setText("我的用户名:" + Info.user.userName + "");
        if (!TextUtils.isEmpty(userid)) {
            String textContent = userid;
            //带有logo
//        mBitmap = CodeUtils.createImage(textContent, 400, 400, BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher));
            mBitmap = CodeUtils.createImage(textContent, 400, 400, null);
            zxingimg.setImageBitmap(mBitmap);
        } else {
            Toast.makeText(ZxingActivity.this, "您还未登录哦", Toast.LENGTH_SHORT).show();
        }

    }

    @Override
    protected int setContentView() {
        return R.layout.activity_zxing;
    }
}
